package com.fjec.devops.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjec.common.jxls.BreakfastExcel;
import com.fjec.common.jxls.DataSixUpload;
import com.fjec.common.view.RpcReturnPage;
import com.fjec.devops.entity.InfoMarket;
import com.fjec.devops.feign.fallback.MarketClientFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@FeignClient(name = "market-serv", fallback = MarketClientFallback.class)
public interface MarketClient {
    @RequestMapping(method = RequestMethod.GET, value = "/api/market/devOps/list")
    Map<String, Object> getMarkets(@RequestParam("page") int page, @RequestParam("limit") int limit);

    @RequestMapping(method = RequestMethod.GET, value = "/api/market/devOps/getByCode")
    Map<String, Object> getMarketByMarkCode(@RequestParam("markCode") int markCode);

    @RequestMapping(method = RequestMethod.POST, value = "/api/market/devOps/saveOrUpdate")
    int saveOrUpdate(@RequestBody InfoMarket infoMarket,
                     @RequestParam("markPic") String markPic,
                     @RequestParam("markMapPic") String markMapPic);

    @RequestMapping(method = RequestMethod.GET, value = "/api/market/getBusinessesOfAllTypesByConditions")
    Map<String, Object> getBusinessesOfAllTypesByConditions(@RequestParam("searchBy") Integer searchBy,
                                                            @RequestParam("title") String title,
                                                            @RequestParam("busiType") Integer busiType,
                                                            @RequestParam("markCode") Integer markCode,
                                                            @RequestParam("startTime") String startTime,
                                                            @RequestParam("endTime") String endTime,
                                                            @RequestParam("page") Long page,
                                                            @RequestParam("limit") Long limit);

    @RequestMapping(method = RequestMethod.GET, value = "/api/market/shop/getBusinessInfo")
    Map<String, Object> getBusinessInfo(@RequestParam("busiId") Long busiId, @RequestParam("busiType") Integer busiType);

    @RequestMapping(method = RequestMethod.GET, value = "/api/phy/order/getOrdersByConditions")
    Map<String, Object> getOrdersByConditions(@RequestParam("searchBy") Integer searchBy,
                                              @RequestParam("title") String title,
                                              @RequestParam("busiType") Integer busiType,
                                              @RequestParam("markCode") Integer markCode,
                                              @RequestParam("orderType") Integer orderType,
                                              @RequestParam("orderStatus") Integer orderStatus,
                                              @RequestParam("startTime") String startTime,
                                              @RequestParam("endTime") String endTime,
                                              @RequestParam("page") Long page,
                                              @RequestParam("limit") Long limit);

    @RequestMapping(method = RequestMethod.GET, value = "/api/phy/order/getOrdersByBusiId")
    Map<String, Object> getOrdersByBusiId(@RequestParam("busiId") Long busiId,
                                          @RequestParam("page") Long page,
                                          @RequestParam("limit") Long limit);

    @RequestMapping(method = RequestMethod.GET, value = "/api/phy/order/getOrderDetailById")
    Map<String, Object> getOrderDetailById(@RequestParam("id") Long id);

    @RequestMapping(method = RequestMethod.GET, value = "/api/market/deposit/devOps/getDepoInfoByConditions")
    Map<String, Object> getDepoInfoByConditions(@RequestParam("searchBy") Integer searchBy,
                                                @RequestParam("title") String title,
                                                @RequestParam("busiType") Integer busiType,
                                                @RequestParam("markCode") Integer markCode,
                                                @RequestParam("depoStatus") Integer depoStatus,
                                                @RequestParam("timedBy") Integer timedBy,
                                                @RequestParam("startTime") String startTime,
                                                @RequestParam("endTime") String endTime,
                                                @RequestParam("page") Long page,
                                                @RequestParam("limit") Long limit);

    /**
     * 统计果农
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/farmer/data")
    List<Map<String, Object>> statFarmerData(@RequestParam("days") Integer days);

    /**
     * 统计分拣
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/sorting/data")
    List<Map<String, Object>> statSortingPlantData(@RequestParam("days") Integer days);

    /**
     * 统计农资
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/material/data")
    List<Map<String, Object>> statMaterialData(@RequestParam("days") Integer days);

    /**
     * 统计包装
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/pkg/data")
    List<Map<String, Object>> statPkgPlantData(@RequestParam("days") Integer days);

    /**
     * 统计采购
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/purchase/data")
    List<Map<String, Object>> statPurchaseData(@RequestParam("days") Integer days);


    /**
     * 统计所有用户数量
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/all/personal/data")
    List<Map<String, Object>> statAllPersonalData(@RequestParam("days") Integer days);

    /**
     * 统计普通用户数量
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/personal/data")
    List<Map<String, Object>> statPersonalData(@RequestParam("days") Integer days);

    /**
     * 统计订单数量，金额
     *
     * @param days
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/sub/order/data")
    List<Map<String, Object>> statSubOrderNumData(@RequestParam("days") Integer days);

    /**
     * 获取所有市场
     *
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/stat/get/all/market")
    List<Map<String, Object>> getAllMarket();

    /**
     * 交易流水列表
     *
     * @param searchBy
     * @param title
     * @param orderType
     * @param sellerType
     * @param buyerType
     * @param page
     * @param limit
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/market/order/getTradingsByConditions")
    Map<String, Object> getTradingsByConditions(@RequestParam("searchBy") Integer searchBy,
                                                @RequestParam("title") String title,
                                                @RequestParam("orderType") Integer orderType,
                                                @RequestParam("sellerType") Integer sellerType,
                                                @RequestParam("buyerType") Integer buyerType,
                                                @RequestParam("page") Long page,
                                                @RequestParam("limit") Long limit);


    @RequestMapping(method = RequestMethod.GET, value = "/api/phy/order/getOrderComplaintsByConditions")
    Map<String, Object> getOrderComplaintsByConditions(@RequestParam("searchBy") Integer searchBy,
                                                       @RequestParam("title") String title,
                                                       @RequestParam("busiType") Integer busiType,
                                                       @RequestParam("markCode") Integer markCode,
                                                       @RequestParam("orderType") Integer orderType,
                                                       @RequestParam("orderStatus") Integer orderStatus,
                                                       @RequestParam("startTime") String startTime,
                                                       @RequestParam("endTime") String endTime,
                                                       @RequestParam("page") Long page,
                                                       @RequestParam("limit") Long limit);

    @RequestMapping(method = RequestMethod.POST, value = "/api/phy/order/complaint/handle")
    int handleComplaint(@RequestParam("orderId") Long orderId,
                        @RequestParam("subOrderId") Long subOrderId,
                        @RequestParam("complaintId") Long complaintId,
                        @RequestParam("handleType") Integer handleType,
                        @RequestParam("amount") String amount,
                        @RequestParam("complaintText") String complaintText);

    /**
     * 获取指定一天的线上进件成功列表
     *
     * @param dateTime
     * @return
     * @throws Exception
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/ys/offline/reg/list")
    List<Map<String, Object>> getOffLineRegList(@RequestParam("dateTime") String dateTime);

    /**
     * 更新线下进件状态
     *
     * @param dataList
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/ys/offline/reg/result")
    Map<String, Object> updateOffLineRegResult(@RequestBody List<DataSixUpload> dataList);

    /**
     * 更新市场轮播图
     *
     * @param markCode
     * @param marketRotation
     * @return
     */
    @RequestMapping(method = RequestMethod.POST, value = "/api/market/update/rotation")
    boolean updateMarketRotation(@RequestParam Integer markCode,
                                 @RequestBody List<Map<String, Object>> marketRotation);

    @RequestMapping(method = RequestMethod.GET, value = "/api/ys/get/account/info")
    Map<String, Object> getAccountInfo(@RequestParam("busiId") Long busiId);

    @RequestMapping(method = RequestMethod.POST, value = "/api/refund/deposit")
    int refundDeposit(@RequestParam("busiId") Long busiId, @RequestParam("busiType") Integer busiType);

    /**
     * 搜索早餐店铺订单信息
     *
     * @param current
     * @param size
     * @param shopId      早餐店铺Id
     * @param subOrderId  子订单Id
     * @param busiType    早餐店铺类型
     * @param orderType   订单类型
     * @param orderStatus 订单状态
     * @param startTime   开始时间
     * @param endTime     结束时间
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/breakfast/get/order/page")
    RpcReturnPage<Map<String, Object>> rpcGetOrderForBreakfast(@RequestParam long current,
                                                               @RequestParam long size,
                                                               @RequestParam(required = false) Long shopId,
                                                               @RequestParam(required = false) Long subOrderId,
                                                               @RequestParam(required = false) Integer busiType,
                                                               @RequestParam(required = false) Integer orderType,
                                                               @RequestParam(required = false) Integer orderStatus,
                                                               @RequestParam(required = false) String startTime,
                                                               @RequestParam(required = false) String endTime
    );

    /**
     * 查询早餐店铺订单信息，生成excel用
     *
     * @param shopId
     * @param busiType
     * @param date
     * @return
     */
    @RequestMapping(method = RequestMethod.GET, value = "/api/breakfast/get/order/excel")
    List<BreakfastExcel> rpcGetOrderForBreakfastExcel(@RequestParam Long shopId,
                                                      @RequestParam Integer busiType,
                                                      @RequestParam String date
    );
}
